package com.liaowei.workmanager

import android.annotation.SuppressLint
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.ViewModelProvider
import com.liaowei.workmanager.databinding.ActivityMainBinding

@SuppressLint("RestrictedApi")
class MainActivity : AppCompatActivity() {

    private lateinit var binding: ActivityMainBinding
    private val viewmodel by viewModels<MainViewModel>{
        ViewModelProvider.NewInstanceFactory.instance
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        binding.button.setOnClickListener {
            viewmodel.add()
        }
        viewmodel.number.observe(this){
            binding.textView.text = it.toString()
        }
    }
}